<?php $week= explode(",", $detail['weekday']);?>
<style type="text/css">
	label{width:130px!important;}
</style><?php $today=getdate(); ?><script>
	$(function(){
		$('*[name=timearrive]').appendDtpicker({"locale":"ja"});
		$('*[name=timedeparture]').appendDtpicker({"locale":"ja"});
	});
</script>
<div id="box">
  <form action="<?php echo base_url(); ?>admin/flight/<?php if(isset($_GET['id'])) echo "update?id=".$_GET["id"];else echo "insert";?>" method="post" enctype="multipart/form-data">
    <fieldset id="personal">
      <legend>&nbsp;&nbsp;Edit Flight&nbsp;&nbsp;</legend>
      <label>ID : </label>
      <?php if(count($detail)>0) echo $detail['id'];else echo "ID"; ?>
      <br>
      <label>Avatar : </label>
      <input name="fuavatar" type="file">
      <img src="<?php echo $detail["avatar"];?>" width="150"/>
      <br>
      <label>Description : </label>
      <?php 
										$fck = new FCKeditor('description');
										$fck->BasePath = sBASEPATH;
								        $fck->Value  = $detail['description'];					
										$fck->Width  = '100%';
										$fck->Height = 400;
										$fck->Create();
									   ?>
                                       <br />
      <label>From : </label>
      <select name="fromplace">
        <option value="0" <?php if($detail['fromplace']==0) echo "selected"; ?>>Depart from</option>
        <option value="Nyaung-U (Bagan)" <?php if($detail['fromplace']=="Nyaung-U (Bagan)") echo "selected"; ?>>Nyaung-U (Bagan)</option>
        <option value="Heho (Inle)" <?php if($detail['fromplace']=="Heho (Inle)") echo "selected"; ?>>Heho (Inle)</option>
        <option value="Mandalay" <?php if($detail['fromplace']=="Mandalay") echo "selected"; ?>>Mandalay</option>
        <option value="Yangon" <?php if($detail['fromplace']=="Yangon") echo "selected"; ?>>Yangon</option>
      </select>
      <br />
      <label>To : </label>
      <select name="destination">
        <option value="0" <?php if($detail['destination']==0) echo "selected"; ?>>Arrive to</option>
        <option value="Nyaung-U (Bagan)" <?php if($detail['destination']=="Nyaung-U (Bagan)") echo "selected"; ?>>Nyaung-U (Bagan)</option>
        <option value="Heho (Inle)" <?php if($detail['destination']=="Heho (Inle)") echo "selected"; ?>>Heho (Inle)</option>
        <option value="Mandalay" <?php if($detail['destination']=="Mandalay") echo "selected"; ?>>Mandalay</option>
        <option value="Yangon" <?php if($detail['destination']=="Yangon") echo "selected"; ?>>Yangon</option>
      </select>
      <br>
      <label>Time Departure : </label>
      <input name="timedeparture" type="text" value="<?php if(count($detail)>0) echo date('H:s',strtotime($detail['timedeparture']));else echo $today['hours'].":".$today['minutes']; ?>" tabindex="2">
      <br>
      <label>Time Arrive : </label>
      <input name="timearrive" type="text" value="<?php if(count($detail)>0) echo date('H:s',strtotime($detail['timearrive']));else echo $today['hours'].":".$today['minutes']; ?>" tabindex="2">
      <br />
      <label>Duration : </label>
      <input name="duration" value="<?php echo $detail['duration'] ?>" />
      <br />
      <div style="width:100%;float:left;">
      <label>Day Of Week : </label>      
      <input type="checkbox" class="dayofweek0" value="allday" onclick="dropotherweekday();" <?php for($i=0;$i<count($week);$i++){ if($week[$i]=="allday") echo "checked='checked'";}?> style="float:left;margin-top:2px" /><span style="float:left;padding:0 10px 0 3px;">All day</span>
      <input type="checkbox" class="dayofweek1" value="Sunday" onclick="dropallday();" <?php for($i=0;$i<count($week);$i++){ if($week[$i]=="Sunday") echo "checked='checked'";}?> style="float:left;margin-top:2px" /><span style="float:left;padding:0 10px 0 3px;">Sunday</span>
      <input type="checkbox" class="dayofweek2" value="Monday" onclick="dropallday();" <?php for($i=0;$i<count($week);$i++){ if($week[$i]=="Monday") echo "checked='checked'";}?> style="float:left;margin-top:2px" /><span style="float:left;padding:0 10px 0 3px;">Monday</span>
      <input type="checkbox" class="dayofweek3" value="Tuesday" onclick="dropallday();" <?php for($i=0;$i<count($week);$i++){ if($week[$i]=="Tuesday") echo "checked='checked'";}?> style="float:left;margin-top:2px" /><span style="float:left;padding:0 10px 0 3px;">Tuesday</span>
      <input type="checkbox" class="dayofweek4" value="Wednesday" onclick="dropallday();" <?php for($i=0;$i<count($week);$i++){ if($week[$i]=="Wednesday") echo "checked='checked'";}?> style="float:left;margin-top:2px" /><span style="float:left;padding:0 10px 0 3px;">Wednesday</span>
      <input type="checkbox" class="dayofweek5" value="Thursday" onclick="dropallday();" <?php for($i=0;$i<count($week);$i++){ if($week[$i]=="Thursday") echo "checked='checked'";}?> style="float:left;margin-top:2px" /><span style="float:left;padding:0 10px 0 3px;">Thursday</span>
      <input type="checkbox" class="dayofweek6" value="Friday" onclick="dropallday();" <?php for($i=0;$i<count($week);$i++){ if($week[$i]=="Friday") echo "checked='checked'";}?> style="float:left;margin-top:2px" /><span style="float:left;padding:0 10px 0 3px;">Friday</span>
      <input type="checkbox" class="dayofweek7" value="Saturday" onclick="dropallday();" <?php for($i=0;$i<count($week);$i++){ if($week[$i]=="Saturday") echo "checked='checked'";}?> style="float:left;margin-top:2px" /><span style="float:left;padding:0 10px 0 3px;">Saturday</span>
      <input type="hidden" id="weekday" name="weekday"/>
      </div>
    <script type="text/javascript">
    	function dropotherweekday(){			
			for(var n=1;n<=7;n++){	
				$('.dayofweek'+n).prop('checked',false);
			}
		}
		function dropallday(){
			$('.dayofweek0').prop('checked',false);	
		}
    </script>
      <br>
      <label>Airline : </label>
      <select name="airline">
        <option value="0" <?php if($detail['airline']==0) echo "selected"; ?>>Choose Airline</option>
        <option value="1" <?php if($detail['airline']==1) echo "selected"; ?>>Air Bagan</option>
        <option value="2" <?php if($detail['airline']==2) echo "selected"; ?>>Air Mandalay</option>
        <option value="3" <?php if($detail['airline']==3) echo "selected"; ?>>Air KBZ</option>
        <option value="4" <?php if($detail['airline']==4) echo "selected"; ?>>Golden Myanmar Airlines</option>
        <option value="5" <?php if($detail['airline']==5) echo "selected"; ?>>Yangon Airways</option>
        <option value="6" <?php if($detail['airline']==6) echo "selected"; ?>>Asian Wings</option>
      </select>
       <br>
      <label>Flight Number : </label>
      <input name="codeofairline" type="text" value="<?php echo $detail['codeofairline']; ?>"/>
       <br>
      <label>Stop : </label>
      <select name="stop">
      	<option value="0" <?php if($detail['stop']==0) echo "selected"; ?>>Choose Stop</option>
        <option value="1" <?php if($detail['stop']==1) echo "selected"; ?>>1 Stop</option>
        <option value="2" <?php if($detail['stop']==2) echo "selected"; ?>>Non-Stop</option>
      </select>
      <br>
      
  		<label>Type of Flight : </label>
         <input name="type" type="text" value="<?php echo $detail['type']; ?>" tabindex="2">
      <br />
      <label>Status : </label>
      <select name="status">
        <option value="0">Choice Status</option>
        <option value="1" <?php if($detail['status']==1) echo "selected"; ?>>Highlights</option>
        <option value="2" <?php if($detail['status']==2) echo "selected"; ?>>Normal</option>
        <option value="3" <?php if($detail['status']==3) echo "selected"; ?>>Hidde</option>
      </select>
      <br />
      <div style="float:left;padding-top:5px;padding-left:40%;">
        <input type="reset" value="Reset">
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" onclick="return checkdayofweek();" value="Submit">
      </div>
    </fieldset>
  </form>
</div>
<script>			
	weekday=[];
	function checkdayofweek(){
		for(var i=0;i<=7;i++){
			if($('.dayofweek'+i).is(':checked')==true){
				weekday.push($('.dayofweek'+i).val());
			}else{
				
			}
		}	
		$('#weekday').val(weekday);
	}
</script>
